package cn.teleware.api.annotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author : hongsw
 * @date : 2020-11-12-14:33
 * @descriptions :
 */
public class WeakPasswordValidator implements ConstraintValidator<WeakPassword, String> {
    /**
     * 初始化
     *
     * @param constraintAnnotation 注解
     * @author hongsw
     * @date 2020/11/12 14:38
     **/
    @Override
    public void initialize(WeakPassword constraintAnnotation) {
        System.out.println("constraintAnnotation:" + constraintAnnotation);
    }

    /**
     * 校验规则
     *
     * @param value                      前端传入的参数
     * @param constraintValidatorContext 错误信息模板上下文
     * @return boolean
     * @author hongsw
     * @date 2020/11/12 14:39
     **/
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        return value.length() > 10;
    }
}
